package org.visionlibrary.image.model;

import java.awt.Point;

public class ConvolutionKernel {
	protected int height;
	protected int width;
	protected Point origin;
	protected float[] values;
	protected float divisor;

	public ConvolutionKernel(int height, int width, float[] values,
			float divisor) {
		if (values == null)
			return;

		this.height = height;
		this.width = width;
		this.values = new float[values.length];
		System.arraycopy(values, 0, this.values, 0, values.length);
		this.divisor = divisor;
	}

	public ConvolutionKernel(int height, int width, float[] values,
			float divisor, Point origin) {
		this(height, width, values, divisor);

		this.origin = origin;
	}

	public int getHeight() {
		return height;
	}

	public float getDivisor() {
		return divisor;
	}

	public void setDivisor(float divisor) {
		this.divisor = divisor;
	}

	public Point getOrigin() {
		return origin;
	}

	public void setOrigin(Point origin) {
		this.origin = origin;
	}

	public int getWidth() {
		return width;
	}

	public float getValue(Point p) {
		return values[p.y * this.width + p.x];
	}

	public float[] getKernelData() {
		float[] values = new float[this.values.length];
		System.arraycopy(this.values, 0, values, 0, this.values.length);
		return values;
	}
}
